<?php
/**
 * Created by PhpStorm.
 * User: td
 * Date: 15/1/9
 * Time: 上午12:32
 */

namespace Home\Controller;
use Think\Controller;

class PublisherController extends Controller {

    //发活者登陆首页
    public function index(){
        loginStatus();
        $this->display();
    }

    public function publish() {
        $this->display('publish');
    }

    //发活首页信息获取
    public function publisherIndex(){
        loginStatus();
        $user_ext_db = D('UserExt');
        $jobs = $_GET['jobs'];
        $duration = $_GET['duration'];
//        dump($jobs);
        if(IS_GET){
            $result = $user_ext_db->getYInfo($jobs,$duration);
            if($result){
                $this->success('获取信息成功!',$result);
            }else{
                $this->error('获取信息失败!');
            }

        }else{
            $this->error('错误方法!');
        }
    }


    //发活页面
    public function publishMission(){
        loginStatus();
        //$this->display('Login/index');
        $user_info = $_SESSION['loginUser'];
        //publisher_id
        $data['publisher_id'] = $user_info['user_id'];
        //publish_time
        ini_set('date.timezone','Asia/Shanghai');
        $data['publish_time'] = date('Y-m-d H:i:s',time());
        //提交得信息
        $data['mission_name'] = $_POST['mission_name'];
        $data['jobs'] = $_POST['jobs'];
        $data['duration'] = $_POST['duration'];
        $data['salary1'] = $_POST['salary1'];
        $data['salary2'] = $_POST['salary2'];
        $data['location1'] = $_POST['location1'];
        $data['location2'] = $_POST['location2'];
        $data['description'] = $_POST['description'];
        $data['valid_time'] = $_POST['valid_time'];
        $data['isagent'] = $_POST['isagent'];
        $data['isphone_public'] = $_POST['isphone_public'];

        //设置状态
        $data['status'] = 1;
        //mission表存入信息
        $mission_db = M('Mission');
        $mission_result = $mission_db->add($data);

        if($mission_result){

            $this->success("发布成功!");
        }else{
            $this->error("发布失败!");
        }

    }


} 